import React from "react";
import { basicIp, newHttpService } from "../../../api/http";

///gb-system-set/systemDetail
export const getGbSystemSetSystemDetail = () => {
  const url = basicIp + "/gb-system-set/systemDetail";
  return newHttpService.getData(url);
};

export interface ISystemSetSystemType {
  id: number;
  weightLimit: number; //限重设置（吨）
  weightDisplay: number; //重车下调重量显示(吨)
}

//gb-system-set/systemSet
export const postGbSystemSetSystemSet = (data: ISystemSetSystemType) => {
  const url = basicIp + "/gb-system-set/systemSet";
  return newHttpService.postData(url, data);
};

//gb-system-set/goodsList 货品列表
export const getGbSystemSetGoodsList = () => {
  const url = basicIp + "/gb-system-set/goodsList";
  return newHttpService.getData(url);
};

export interface IgoodsType {
  id?: number;
  goodName: string;
}

//gb-system-set/addGoods 添加货品
export const postGbSystemSetAddGoods = (data: IgoodsType) => {
  const url = basicIp + "/gb-system-set/addGoods";
  return newHttpService.postData(url, data);
};

//gb-system-set/updateGoods 编辑货品
export const postGbSystemSetUpdateGoods = (data: IgoodsType) => {
  const url = basicIp + "/gb-system-set/updateGoods";
  return newHttpService.postData(url, data);
};

//gb-system-set/deleteGoods 删除货品
export const postGbSystemSetDeleteGoods = (data: { id?: number }) => {
  const url = basicIp + "/gb-system-set/deleteGoods";
  return newHttpService.getData(url, data);
};

export interface IMonitorType {
  id: number;
  rtspAddress: string;
  saveLocation: string;
  clipVideoBefore: number;
  clipVideoAfter: number;
  channelNum: number;
}

//gb-system-set/allMonitor 全部流程监控设置
export const postSetAllMonitor = (data: IMonitorType) => {
  const url = basicIp + "/gb-system-set/allMonitor";
  return newHttpService.postData(url, data);
};

export interface ICarIndentifyType {
  id: number;
  barrierPort: number;
  deviceNumber: string;
  ipAddress: string;
  password: string;
  sdkPort: number;
  sign: string;
  userName: string;
}

export interface ICatchSet {
  id: number;
  catchName: string;
  deviceNumber: string;
  ipAddress: string;
  password: string;
  sdkPort: string;
  userName: string;
}

//gb-system-set/catch 抓拍机设置
export const postGbSystemSetCatch = (data: ICarIndentifyType) => {
  const url = basicIp + "/gb-system-set/catch";
  return newHttpService.postData(url, data);
};

//gb-system-set/carIndentify 车号识别信息设置
export const postGbSystemSetCarIndentify = (data: ICarIndentifyType) => {
  const url = basicIp + "/gb-system-set/carIndentify";
  return newHttpService.postData(url, data);
};

//gb-system-set/poundList 磅单列表
export const getGbSystemSetPoundList = () => {
  const url = basicIp + "/gb-system-set/poundList";
  return newHttpService.getData(url);
};
export interface IPoundTypeLedList {
  id: React.Key; //led屏幕id
  ledIp: string; // led屏幕IP
  ledPort: number; // led端口号
  zoneId: React.Key; // 分区ID
  isSwitch: 0 | 1; // led屏幕开关
}
export interface IPoundTypeSpeakList {
  httpAddress: string; //HTTP接口地址
  id: React.Key; //音柱id
  instanceApiKey: string; //实例API_KEY
  instanceKey: string; //实例KEY
  repeatInterval: number; //重复播放间隔（单位：秒）
  repeatTimes: number; //重复次数
  terminalId: string; //终端ID
  voiceType: string; // 播放声音类型(0:男生,1:女生)
  isSwitch: 0 | 1; // 音柱开关
}
export interface IPoundType {
  id: React.Key;
  carIndentifyList: ICarIndentifyType[];
  monitorList: IMonitorType;
  catchList: ICatchSet[];
  poundName: string;
  sensorList: ISensorType;
  weightReadList: IWeightReadType;
  toleranceRange: number;
  ledList: IPoundTypeLedList;
  speakList: IPoundTypeSpeakList;
  cardNum: string; // 磅房二维码设备序列号
}

//gb-system-set/addPound 添加磅单
export const postGbSystemSetAddPound = (data: { poundName: string }) => {
  const url = basicIp + "/gb-system-set/addPound";
  return newHttpService.postData(url, data);
};

export interface ISensorType {
  id: number;
  barrierPort: string;
  deviceNumber: string;
  ipAddress: string;
  password: string;
  sdkPort: string;
  userName: string;
}

//gb-system-set/sensorSet
export const postGbSystemSetSensorSet = (data: ISensorType) => {
  const url = basicIp + "/gb-system-set/sensorSet";
  return newHttpService.postData(url, data);
};

export interface IWeightReadType {
  id: number;
  barrierPort: string;
  deviceNumber: string;
  ipAddress: string;
  password: string;
  sdkPort: string;
  userName: string;
}

//gb-system-set/weightRead
export const getGbSystemSetWeightRead = (data: IWeightReadType) => {
  const url = basicIp + "/gb-system-set/weightRead";
  return newHttpService.postData(url, data);
};

//gb-system-set/deletePound 删除
export const postGbSystemSetDeletePound = (data: { id?: number }) => {
  const url = basicIp + "/gb-system-set/deletePound";
  return newHttpService.getData(url, data);
};

//gb-system-set/setRange 设置范围
export const postGbSystemSetSetRange = (data: {
  id?: React.Key;
  toleranceRange: number;
}) => {
  const url = basicIp + "/gb-system-set/setRange";
  return newHttpService.getData(url, data);
};
// LED 参数设置
export interface IGbSystemSetLedSetParams {
  id: React.Key; // led屏幕id
  ledIp: string; // led屏幕IP
  ledPort: number; // Led 端口号
  zoneId: React.Key; // 分区ID 1 2 3
}
export const postGbSystemSetLedSet = (data: IGbSystemSetLedSetParams) => {
  const url = basicIp + "/gb-system-set/ledSet";
  return newHttpService.postData(url, data);
};
// 设置广告
export interface IGbSystemSetAdvertisingSetParams {
  id: React.Key;
  text: string; // 广告内容
}
export const postGbSystemSetAdvertisingSet = (
  data: IGbSystemSetAdvertisingSetParams
) => {
  const url = basicIp + "/gb-system-set/advertisingSet";
  return newHttpService.postData(url, data);
};
// 设置亮度
export const getGbSystemSetLuminance = (data: {
  id: React.Key;
  luminance: number;
}) => {
  const url = basicIp + "/gb-system-set/luminance";
  return newHttpService.getData(url, data);
};
// LED开机
export const getGbSystemSetStart = (data: { id: React.Key }) => {
  const url = basicIp + "/gb-system-set/start";
  return newHttpService.getData(url, data);
};
// LED关机
export const getGbSystemSetShutDown = (data: { id: React.Key }) => {
  const url = basicIp + "/gb-system-set/shutDown";
  return newHttpService.getData(url, data);
};
// LED 测试
export interface IGbSystemSetTestLimitParams {
  id: React.Key; //led屏幕id
  text: string; // 广告内容
  timeOut: number; // 时间显示时长（秒）
}
export const postGbSystemSetTestLimit = (data: IGbSystemSetTestLimitParams) => {
  const url = basicIp + "/gb-system-set/testLimit";
  return newHttpService.postData(url, data);
};
// 音柱设置
export interface IGbSystemSetSoundSetParams {
  id: React.Key; // 音柱id
  httpAddress: string; // HTTP接口地址
  instanceKey: string; // 实例KEY
  instanceApiKey: string; // 实例API_KEY
  terminalId: string; // 终端ID
  voiceType: string; // 播放声音类型(0:男生,1:女生)
  repeatTimes: number; // 重复次数
  repeatInterval: number; // 重复播放间隔（单位：秒）
}
export const postGbSystemSetSoundSet = (data: IGbSystemSetSoundSetParams) => {
  const url = basicIp + "/gb-system-set/soundSet";
  return newHttpService.postData(url, data);
};
// 音柱测试
export const postGbSystemSetSoundTest = (data: {
  id: React.Key;
  text: string;
}) => {
  const url = basicIp + "/gb-system-set/soundTest";
  return newHttpService.postData(url, data);
};

// LED屏幕开关
export interface IGbSystemSetLedSwitchParams {
  id: React.Key;
  isSwitch: "0" | "1";
}
export const getGbSystemSetLedSwitch = (data: IGbSystemSetLedSwitchParams) => {
  const url = basicIp + "/gb-system-set/ledSwitch";
  return newHttpService.getData(url, data);
};
// 音柱开关
export interface IGbSystemSetSoundSwitchParams {
  id: React.Key;
  isSwitch: "0" | "1";
}
export const getGbSystemSetSoundSwitch = (data: IGbSystemSetSoundSwitchParams) => {
  const url = basicIp + "/gb-system-set/soundSwitch";
  return newHttpService.getData(url, data);
};
// 获取磅房二维码
export const getGbSystemSetGetCodeId = (data: {id: React.Key}) => {
  const url = basicIp + '/gb-system-set/getCodeId';
  return newHttpService.getData(url, data);
}
// 设置磅房二维码设备序列号
export const getGbSystemSetSetQrCode = (data: {id: React.Key, cardNum: string}) => {
  const url = basicIp + '/gb-system-set/setQrCode';
  return newHttpService.getData(url, data);
}
